
<%
//note: DB.asp not included here because it is included in the page that also includes this model

var AdminScriptManagerModel = function(){	
	
	this.Scripts = {};
	
	/*----------------------------------------------------------------------*/
	this.Init = function(){

		this.LoadScripts();
	}


	/*----------------------------------------------------------------------*/
	this.LoadScripts = function(){
		var db, rs;
		db = new DB.DataCall();
		db.QueryName =			"qryGetScripts";
		db.ConnectionString =	DB.ConnectionStrings.Scripts;
		db.CommandType =		DB.CommandTypes.StoredProc;
					
		db.Execute();	

		if(db.Success){
			if(db.RecordSet.RecordCount > 0){
				var rs = db.RecordSet;
				rs.MoveFirst();
					
				while(!rs.EOF){
					var script = {
						ScriptID:	db.RecordSet.fields("ScriptID").value
						, Title: 	Helpers.DecodeHTML(db.RecordSet.fields("Title").value)
						, Category: Helpers.DecodeHTML(db.RecordSet.fields("Category").value)
					}

					if(!this.Scripts[script.Category])
						this.Scripts[script.Category] = [];

					this.Scripts[script.Category].push(script);
						
					rs.MoveNext();
				}
	
			}//recordcount > 0
		}//db.Success
	}

}

%>